package com.itxiuyixiu.homework.admin.controller;

import com.itxiuyixiu.homework.admin.service.ExcelService;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

/**
 * @author 黄磊
 * @date 2020/4/13
 */
@RestController
public class ExcelController {
    @Autowired
    private ExcelService excelService;

    @GetMapping("/admin/excel")
    public void getCourseRecord(HttpServletResponse response) throws Exception{
        Workbook excel = excelService.getCourseRecordExcel();
        response.setContentType("application/force-download");
        response.addHeader("Content-Disposition", "attachment;fileName=aaa.xlsx");
        excel.write(response.getOutputStream());
    }
}
